import unittest
import requests
from ddt import ddt, data, unpack
import csv


def get_csv_data(file_path):
    # 读取CSV文件并返回测试数据
    with open(file_path, 'r') as f:
        reader = csv.DictReader(f)
        return [(row['username'], row['password']) for row in reader]


@ddt
class A3mall1(unittest.TestCase):

    # 从CSV加载数据
    @data(*get_csv_data('login.csv'))
    @unpack
    def test_A3mall_01(self, username, password):
        # 测试登录接口
        login = requests.post(
            url='http://10.59.9.14:7003/api/public/login',
            json={"username": username, "password": password}
        )
        print(login.json())

